﻿using System;
using UnityEngine;

// Token: 0x0200013D RID: 317
[RequireComponent(typeof(VehicleParent))]
[AddComponentMenu("RVP/C#/Input/Mobile Input Getter", 2)]
[DisallowMultipleComponent]
public class MobileInputGet : MonoBehaviour
{
	// Token: 0x060005CA RID: 1482 RVA: 0x0002DE5F File Offset: 0x0002C05F
	private void Start()
	{
		this.vp = base.GetComponent<VehicleParent>();
		this.setter = UnityEngine.Object.FindObjectOfType<MobileInput>();
	}

	// Token: 0x060005CB RID: 1483 RVA: 0x0002DE78 File Offset: 0x0002C078
	private void FixedUpdate()
	{
		if (this.setter)
		{
			this.accelerationDelta = Input.acceleration - this.accelerationPrev;
			this.accelerationPrev = Input.acceleration;
			this.vp.SetAccel(this.setter.accel);
			this.vp.SetBrake(this.setter.brake);
			this.vp.SetEbrake(this.setter.ebrake);
			this.vp.SetBoost(this.setter.boost);
			if (this.useAccelerometer)
			{
				this.vp.SetSteer((Input.acceleration.x + this.accelerationDelta.x * this.deltaFactor) * this.steerFactor);
				this.vp.SetYaw(Input.acceleration.x * this.flipFactor);
				this.vp.SetPitch(-Input.acceleration.z * this.flipFactor);
			}
			else
			{
				this.vp.SetSteer(this.setter.steer);
			}
		}
	}

	// Token: 0x0400086A RID: 2154
	private VehicleParent vp;

	// Token: 0x0400086B RID: 2155
	private MobileInput setter;

	// Token: 0x0400086C RID: 2156
	public float steerFactor = 1f;

	// Token: 0x0400086D RID: 2157
	public float flipFactor = 1f;

	// Token: 0x0400086E RID: 2158
	public bool useAccelerometer = true;

	// Token: 0x0400086F RID: 2159
	[Tooltip("Multiplier for input addition based on rate of change of input")]
	public float deltaFactor = 10f;

	// Token: 0x04000870 RID: 2160
	private Vector3 accelerationPrev;

	// Token: 0x04000871 RID: 2161
	private Vector3 accelerationDelta;
}
